<?php /*debugvar($arBranch); */?>
<?php /*debugvar('Level: ' . $level); */?>
<?php if( !empty($arBranch) ): ?>
    <?php foreach($arBranch as $key => $ar): ?>
        <div style='width: 550px; font-family: Courier New;'>
        <div style='padding-left: <?php echo (20 * $level) ?>px; float: left; width: <?php echo 400 - 20*$level ?>px; border: solid 1px #cccccc; margin-bottom: 5px;'>
        <?php echo link_to(
                        image_tag(
                            'bullet_arrow_up.png'
                            , array(
                                'border' => '0'
                                , 'alt' => __('Move up')
                                , 'title' => __('Move up')
                            )
                        )
                        , 'tree/moveup?id=' . $ar['obj']->getId()
                    ) ?>

        <?php if( $ar['obj']->getName() ): ?>
            <?php if( $ar['obj']->getObjType() == MyConstants::TYPE_TEXTMODULE ): ?>
                <?php echo link_to($ar['obj']->getName(), 'textmodule/edit?id=' . $ar['obj']->getObjId()) ?>
            <?php elseif( $ar['obj']->getObjType() == MyConstants::TYPE_GALLERY ): ?>
                <?php echo link_to($ar['obj']->getName(), 'gallery/edit?id=' . $ar['obj']->getObjId()) ?>
            <?php elseif( $ar['obj']->getObjType() == MyConstants::TYPE_CATEGORY ): ?>
                <?php echo link_to($ar['obj']->getName(), 'category/edit?id=' . $ar['obj']->getObjId()) ?>
            <?php elseif( $ar['obj']->getObjType() == MyConstants::TYPE_LINK_TO ): ?>
                <?php echo link_to($ar['obj']->getName(), 'tree/linkto?id=' . $ar['obj']->getId()) ?>
            <?php else: ?>
                <?php echo link_to($ar['obj']->getName(), 'tree/selectmodule?id=' . $ar['obj']->getId() . '&module_type=1') ?>
            <?php endif; ?>
        <?php else: ?>
            <span style='color: red'><?php echo __('NOT TRANSLATED') ?></span>
        <?php endif; ?>
        <?php if( $ar['obj']->getLabel() ): ?>
            <b style='color: darkgreen;'><?php echo strtoupper($ar['obj']->getLabel()) ?></b>
        <?php endif; ?>
        <?php echo link_to(
                        image_tag(
                            'picture_add.png'
                            , array(
                                'border' => '0'
                            )
                        )
                        , 'tree/icon?id=' . $ar['obj']->getId()
                        , array(
                            'popup' => array(
                                    'popupWindow'
                                    , 'width=910,height=400,left=320,top=0'
                                    )
                    )) ?>
        </div>

        <div style='float: left; width: 20px;'>
        <?php echo link_to(
                        image_tag(
                            'module_change.png'
                            , array(
                                'border' => '0'
                                , 'alt' => __('Select module')
                                , 'title' => __('Select module')
                            )
                        )
                        , 'tree/selectmodule?id=' . $ar['id']
                    ) ?></div>
        
        <div style='float: left; width: 20px;'>
        <?php echo link_to(
                        image_tag(
                            'script.png'
                            , array(
                                'border' => '0'
                                , 'alt' => __('Set label')
                                , 'title' => __('Set label')
                            )
                        )
                        , 'tree/label?id=' . $ar['id']
                    ) ?></div>
        <div style='float: left; width: 20px;'>
        <?php echo link_to(
                        image_tag('pencil.png'
                            , array(
                                'border' => '0'
                                , 'alt' => __('System info')
                                , 'title' => __('System info')
                            ))
                        , 'tree/edit?id=' . $ar['id']
                    ) ?></div>
        <div style='float: left; width: 20px; margin-left: 10px;'>
        <?php echo link_to(
                        image_tag('add.png'
                            , array(
                                'border' => '0'
                                , 'alt' => __('Add child')
                                , 'title' => __('Add child')
                            ))
                        , 'tree/create?tree_parent_id=' . $ar['id']
                    ) ?></div>
        <div style='float: left; width: 20px;'>
        <?php echo link_to(
                        image_tag('delete.png'
                            , array(
                                'border' => '0'
                                , 'alt' => __('delete')
                                , 'title' => __('delete')
                            ))
                        , 'tree/delete?id=' . $ar['id']
                        , array(
                            'confirm' => __('Are you sure?!')
                            )
                    ) ?></div>
        <?php if( !empty($ar['children']) ): ?>
            <?php /*debugvar($ar['children']) */?>
            <?php include_partial(
                    'tree/branch'
                    , array(
                        'arBranch' => $ar['children']
                        , 'level' => $level + 1
                        , 'userCulture' => $userCulture
                    )
            ) ?>
        <?php endif; ?>

    <?php endforeach; ?>
<?php endif; ?>
